package com.dingdayu.club.admin.adapter;

/**
 * Created by 大小姐 on 2015/10/24.
 */

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.dingdayu.club.admin.R;
import com.dingdayu.club.admin.common.util.ImageLoader;

import org.kymjs.kjframe.KJBitmap;

import java.util.ArrayList;
import java.util.HashMap;

public class EventListAdapter extends BaseAdapter {

    private Activity activity;
    private ArrayList<HashMap<String, String>> data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader; //用来下载图片的类，后面有介绍

    public EventListAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.list_item_event, null);

        TextView title = (TextView)vi.findViewById(R.id.title); // 标题
        TextView artist = (TextView)vi.findViewById(R.id.artist); // 歌手名
        TextView duration = (TextView)vi.findViewById(R.id.duration); // 时长
        TextView count = (TextView)vi.findViewById(R.id.count);


        HashMap<String, String> song = new HashMap<String, String>();
        song = data.get(position);

        // 设置ListView的相关值
        title.setText(song.get("name"));
        artist.setText(song.get("star_time") + " - " + song.get("end_time"));
        count.setText(song.get("count"));
//        if("0.00".equals(song.get("cost"))){
//            duration.setText("暂未审核");
//
//        }else {
//            duration.setText("正式成员");
//        }

        return vi;
        }
}